<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/component/commonTagLib.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <title><spring:message code="message.lable.drugqualityspecSeeStd"/></title>
    <%@ include file="/WEB-INF/component/commonCSS.jsp"%>
    <!--[if lt IE 9]>
        <script src="${ctx}/lib/js/html5shiv.min.js"></script>
        <script src="${ctx}/lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
                            
    <section class="content-header">
        <h1>按地区日汇总</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
            	<li><a href="#">交易</a></li>
                <li><a href="#">统计与查询</a></li>
                <li><a href="#">按地区统计</a></li>
        </ol>
    </section>
        
    <section class="content">
    	<div class="box box-success">
    		<div class="box-header with-border">
    			<h3 class="box-title" id="chartTitle"></h3>
                <div class="box-tools pull-right">
                    <button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
                </div><!-- /.box-tools -->
            </div>
            <div class="box-body mchart">
                <div id="mChart" style="height: 300px; width:98%; padding: 8px;"></div>
            </div>
        </div>
        <div class=" box box-success">
            <div class="box-body">
             <form  id="form" method="post">
                <div class="input">
                	<div class="textalign1">地区：</div>
                    <div class="boxinput">
                       <table style="width:100%;">
                           <tr>
                              <td style="width:33%">
                                <select class="textinput" id="area1" disabled="disabled"  name="area1">
                                <option value="${province }">${provinceName }</option>
                                </select>
                              </td>
                              <td style="width:33%">   
                                <select class="textinput" id="area2" name="area2" ></select>
                                </td>
                                <td style="width:33%">   
                                <select class="textinput" id="area3" name="area3" ></select>
                                </td>
                           </tr> 
                        </table>
                    </div>
                    <div class="textalign">日期<spring:message code="message.yanZheng.maoHao"/></div>
                    <div class="boxinput">
                    		<table style="width:100%">
                    			<tr>
                    				<td style="width:50%">
                    					<input id="startDate" name="startDate" class="textinput" type="text" readonly placeholder="开始日期"  data-date-fmt="yyyy-MM-dd"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')}'})"/>
                    				</td>
                    				<td>&nbsp;-&nbsp;</td>
                    				<td style="width:50%">
                    					<input id="endDate" name="endDate" class="textinput" type="text" readonly placeholder="结束日期"  data-date-fmt="yyyy-MM-dd"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'startDate\')}'})"/>
                    				</td>
                    			</tr>
                    		</table>
                    </div>
                    <div class="textalign" >
                         <button id="selectSpec" type="button" onclick="search();" class="btn btn-success btn-sm"><spring:message code="message.button.seachSpacing"/></button>
                    </div>
                </div>
            </form>
            </div>
          </div>
        <table class="jqgrid" id="gridlist"></table>
        <div id="gridpage"></div>
        <div class=" box box-warning bottongroup">
			<button type="button" onclick="toPsYearAnaByArea();" class="btn btn-primary btn-sm">按年汇总</button>
			<button type="button" onclick="toPsSeaAnaByArea ();" class="btn btn-primary btn-sm">按季度汇总</button>
			<button type="button" onclick="toPsMonthAnaByArea();" class="btn btn-primary btn-sm">按月汇总</button>
        </div>
    </section>
      <%@ include file="/WEB-INF/component/commonJS.jsp"%>
    <script type="text/javascript">
        $(function () {
        	
        	$("#area2").HNSelect({
                url: "${pageContext.request.contextPath}/selectController/getArea.html", data: { ID: '${province}' }, defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                func: function () {
                    $("#area3").HNSelect({
                        parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''><spring:message code="message.select.option"/></option>",
                    });
                }
            });
        	
        	$('#form :input').bind('keydown', function(event) {if (event.keyCode == "13") {search();}}).eq(0).focus();
            $("#gridlist").jqGrid({
                url: "${ctx}/psAnaDruginfo/getPsAnaByArea.html",
                mtype: "post",
                datatype: "json",
                autowidth: true,
                height: 310,
                colNames: [
       					'日期',
                        '地区编码',
                        '地区名称',
                        '采购金额', 
                        '配送金额', 
                        '退货金额',
                        '配送率',
                        '退货率'
                ],
                colModel: [
       					{ name: 'date', width: 100, align:"center", sortable: false},
                        { name: 'areaId', width: 140, align:"center", sortable: false},
                        { name: 'areaName', width: 200, align:"center", sortable: false},
                        { name: 'totalAmount', width: 75, align:"center", sortable: false},
                        { name: 'delAmount', width: 75, align:"center", sortable: false},
                        { name: 'retAmount', width: 75, align:"center", sortable: false},
                        { name: 'delRatio', width: 75, align:"center", sortable: false},
                        { name: 'retRatio', width: 75, align:"center", sortable: false},
                           
                ],
                rowNum: 20,
                rowList: [10, 20, 50,100],
                rownumbers: true,
                pager: "#gridpage",
                multiselect: false, 
                viewrecords: true,
                caption: "按地区统计列表",
                gridComplete:function(){
                    autoRNWidth("gridlist");
                },
                jsonReader: {
                	 repeatitems: false,
                    id: "qualitySpecId"
                },
                loadComplete: function (data) { //完成服务器请求后，回调函数
                	$("#chartTitle").html(data.conditions.chartTitle);
                	var option = {
                        	tooltip: {
                            	trigger: 'axis'
                            },
                                toolbox: {
                                    show: true,
                                    feature: {
                                        mark: { show: true },
                                        dataView: { show: true, readOnly: false },
                                        magicType: { show: true, type: ['line', 'bar'] },
                                        restore: { show: true },
                                        saveAsImage: { show: true }
                                    }
                                },
                                calculable: true,
                                legend: {
                                    data: ['配送率(%)']
                                },
                                xAxis: [
                                    {
                                        type: 'category',
                                        data: eval(data.conditions.yTime)
                                    }
                                ],
                                yAxis: [
                                    {
                                    	type: 'value',
                                        name: '配送率(%)',
                                        axisLabel: {
                                            formatter: '{value}'
                                        }
                                    }
                                ],
                                series: [

                                    {
                                        name: '配送率(%)',
                                        type: 'bar',
                                        data: eval(data.conditions.total)
                                    }
                                ]
                        };
                    	var myChart = echarts.init(document.getElementById('mChart'), theme);
                        myChart.setOption(option);
                }
            });
            $("#gridlist").jqGrid('navGrid', '#gridpage', { add: false, edit: false, del: false, search: false, refresh: false });
            $(window).trigger("resize");
        });
        function search(page) {
        	var data =formatForm("form");
            $("#gridlist").jqGrid('setGridParam',{  
                datatype:'json',
                postData:data,
                page : (page || 1)
            }).trigger("reloadGrid"); //重新载入  
        }
        
        function toPsYearAnaByArea(){
        	window.location.href="${ctx}/psAnaDruginfo/toPsYearAnaByArea.html"; 
        }
        
        function toPsSeaAnaByArea(){
        	window.location.href="${ctx}/psAnaDruginfo/toPsSeaAnaByArea.html"; 
        }
        
        function toPsMonthAnaByArea(){
        	window.location.href="${ctx}/psAnaDruginfo/toPsMonthAnaByArea.html"; 
        }
    </script>
</body>
</html> 
                          
                  
                  